package com.moter.demo01.juc.threadpool;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;

public class ThreeMethod {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        //固定长度的线程池
//        ExecutorService executorService = Executors.newFixedThreadPool(6);
        //长度始终为1的线程池
        ExecutorService executorService = Executors.newSingleThreadExecutor();
        //动态长度的线程池
//        ExecutorService executorService = Executors.newCachedThreadPool();
        for (int i = 0; i < 20; i++) {
            Future<Integer> submit = executorService.submit(() -> {
                System.out.println(Thread.currentThread().getName() + "\tis Running");
                return Integer.parseInt("22ss");
            });
//            System.out.println(submit.get());

        }

        executorService.shutdown();
    }
}
